package com.itheima.factory;

/**
 * @program: design
 * @description:
 * @author: zhanghz001
 * @create: 2020-11-26 18:04
 **/
public class ProductFactory {
    public Product getProduct(String name) {
        if ("car".equals(name)) {
            return new Car();
        } else if ("mobile".equals(name)) {
            return new Mobile();
        } else {
            return new Product() {
                @Override
                public void show() {
                    System.out.println("没有这个产品");
                }
            };
        }
    }
}
